package aimis.repo;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import aimis.domain.Role;

import java.util.List;

public interface RoleRepo extends JpaRepository<Role,Long> {
    @Query("""
            select role from Role as role where 
             :name is null or role.name like %:name%
            """)
    Page<Role> findByQuery(String name, Pageable pageable);
    Role findByName(String name);

    List<Role> findByAuthoritiesId(Long id);
}
